package com.minhphuong.controllers;

import com.minhphuong.entities.*;
import com.minhphuong.bll.*;

import java.util.List;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author QuocMinh
 */
@Controller
public class DefaultController {

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index(ModelMap map, HttpSession session) {
        HelperBLL.LoadGiaoDien(map, session);

        List<NguoiDung> listNguoiDung = NguoiDungBLL.getAllNguoiDung();
        map.addAttribute("listNguoiDung", listNguoiDung);

        //List<SanPham> listSanPham = SanPhamBLL.getAllSanPham();
        List<SanPham> list6SanPhamNewest = SanPhamBLL.get6SanPhamNewest();
        map.addAttribute("list6SanPhamNewest", list6SanPhamNewest);

        List<SanPham> list6SanPhamHot = SanPhamBLL.get6SanPhamHot();
        map.addAttribute("list6SanPhamHot", list6SanPhamHot);

        //List<SanPham> listSanPham = SanPhamBLL.getTopSanPham(6);
        //map.addAttribute("listSanPham", listSanPham);
        return "index";
    }

    @RequestMapping(value = "/GioiThieu/", method = RequestMethod.GET)
    public String GioiThieu(ModelMap map, HttpSession session) {
        HelperBLL.LoadGiaoDien(map, session);

        return "gioithieu";
    }

    @RequestMapping(value = "/KhuyenMai/", method = RequestMethod.GET)
    public String KhuyenMai(ModelMap map, HttpSession session) {
        HelperBLL.LoadGiaoDien(map, session);

        return "coding";
    }

    @RequestMapping(value = "/Download/", method = RequestMethod.GET)
    public String Download(ModelMap map, HttpSession session) {
        HelperBLL.LoadGiaoDien(map, session);

        return "coding";
    }

    @RequestMapping(value = "/LienHe/", method = RequestMethod.GET)
    public String LienHe(ModelMap map, HttpSession session) {
        HelperBLL.LoadGiaoDien(map, session);

        return "coding";
    }

    @RequestMapping(value = "/TinTuc/", method = RequestMethod.GET)
    public String TinTuc(ModelMap map, HttpSession session) {
        HelperBLL.LoadGiaoDien(map, session);

        return "coding";
    }
}
